<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<style>

#cdiTable thead tr td{
	font-size: 16px;
	border-color: blue;
	background-color: yellow;
	padding:4px;
	color: blue;	
}

#sumTr td{
	color: black;	
}

table.tablesorter tbody td {
	color :rgb(71, 115, 255)
}
</style>

<c:if test="${showReport != null }">

<div >

<h2>客訴案件數管報及列表統計</h2>

<c:if test="${not empty reportMap}">
	<div><a href="${excelFileUrl }"><spring:message code="report.download"/></a></div>
</c:if>
 
<table border="1" id="cdiTable" class="tablesorter"  style="width: 1200px;">

	<thead>
	<tr>
		<td>廠區\年度</td>
		<td>品情登錄</td>	
		<td>品保指派</td>	
		<td>品管指派</td>	
		<td>初步調查</td>	
		<td>初步回覆</td>	
		<td>客訴判定</td>	
		<td>真因分析</td>
		<td>永久對策</td>	
		<td>客戶確認</td>	
		<td>處級審核</td>	
		<td>追蹤確認</td>
		<td>未結案</td>
		<td>結案</td>	
		<td>合計</td>
	</tr>
	</thead>
	
	<tbody>
	
	<c:if test="${empty reportMap}">
		<tr>
     		<td colspan="13" >查無客訴資料</td>
     	</tr>
	</c:if>
	
	<c:forEach var="r" items="${reportMap}">
	<tr>
     <td>
     		<c:if test="${groupByType == 'madein'}">
     			${madeinMap[r.key]}
     		</c:if>
     		<c:if test="${groupByType != 'madein'}">
     			${r.key} 
     		</c:if>     		
     </td>
     <c:forEach var="count" items="${r.value}" varStatus="status">
     	<c:if test="${status.index < 11 }">
     		<td><a href="<c:url value="/report08v2/0802_1/find.do?userId=${userId}&groupByType=${groupByType}&salesId=${salesId}&custName=${custName}&groupValue=${r.key}&step=${status.index+1}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate}  " />">${count}</a></td>
     	</c:if>
     	<c:if test="${status.index == 11 }">     		
     		<td><a href="<c:url value="/report08v2/0802_2/find.do?userId=${userId}&groupByType=${groupByType}&salesId=${salesId}&custName=${custName}&groupValue=${r.key}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate}  " />">${count}</a></td>
     	</c:if>
     	<c:if test="${status.index == 12 }">
     		<td> 
     			<a href="<c:url value="/report08v2/0802_3/find.do?userId=${userId}&groupByType=${groupByType}&salesId=${salesId}&custName=${custName}&groupValue=${r.key}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate}  " />">${count}</a>
     		</td>
     	</c:if>
     	<c:if test="${status.index == 13 }">
     		<td>
     			<a href="<c:url value="/report08v2/0802_4/find.do?userId=${userId}&groupByType=${groupByType}&salesId=${salesId}&custName=${custName}&groupValue=${r.key}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate}  " />">${count}</a>
     		</td>
     	</c:if>
     </c:forEach>
	</tr>	
	</c:forEach>	
	
	<tr>
		<td>小計</td>
		<c:if test="${searchType =='mt'}">		
		<c:forEach items="${sum}" var="s" varStatus="status">
			<c:if test="${status.index < 11 }">
				<td><a href="<c:url value="/report08v2/0802_1/find.do?userId=${userId}&salesId=${salesId}&custName=${custName}&step=${status.index+1}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
			<c:if test="${status.index == 11 }">
				<td><a href="<c:url value="/report08v2/0802_5/find.do?userId=${userId}&salesId=${salesId}&custName=${custName}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
			<c:if test="${status.index == 12 }">
				<td><a href="<c:url value="/report08v2/0802_6/find.do?userId=${userId}&salesId=${salesId}&custName=${custName}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate}  " />">${s}</a></td>
			</c:if>
			<c:if test="${status.index == 13 }">
				<td><a href="<c:url value="/report08v2/0802_7/find.do?userId=${userId}&salesId=${salesId}&custName=${custName}&searchByMT=${searchByMT}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
		</c:forEach>		
		</c:if>
		
		<c:if test="${searchType =='time'}">
		<c:forEach items="${sum}" var="s" varStatus="status">
			<c:if test="${status.index < 11 }">
				<td><a href="<c:url value="/report08v2/0802_1/find.do?groupByType=period&groupValue=${startDate}__${endDate}&userId=${userId}&salesId=${salesId}&custName=${custName}&step=${status.index+1}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
			<c:if test="${status.index == 11 }">
				<td><a href="<c:url value="/report08v2/0802_5/find.do?groupByType=period&groupValue=${startDate}__${endDate}&userId=${userId}&salesId=${salesId}&custName=${custName}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
			<c:if test="${status.index == 12 }">
				<td><a href="<c:url value="/report08v2/0802_6/find.do?groupByType=period&groupValue=${startDate}__${endDate}&userId=${userId}&salesId=${salesId}&custName=${custName}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
			<c:if test="${status.index == 13 }">
				<td><a href="<c:url value="/report08v2/0802_7/find.do?groupByType=period&groupValue=${startDate}__${endDate}&userId=${userId}&salesId=${salesId}&custName=${custName}&searchByTIME=${searchByTIME }&startDate=${startDate}&endDate=${endDate} " />">${s}</a></td>
			</c:if>
		</c:forEach>		
		</c:if>
	</tr>
	</tbody>
	
	
	
</table>

</div>

</c:if>

<script>
$(function() {
	$("#cdiTable").tablesorter({
		//widgets: ['zebra']
		}); 
})

</script>
